{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "with open(\"id.txt\" ,\"r\",encoding=\"utf-8\") as f:\n",
    "    alist=f.readlines()\n",
    "district=[ i[:6] for i in alist]\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "650101\n",
      "650102\n",
      "650103\n",
      "650104\n",
      "650105\n",
      "650106\n",
      "650107\n",
      "650108\n",
      "650121\n",
      "650201\n",
      "650202\n",
      "650203\n",
      "650204\n"
     ]
    }
   ],
   "source": [
    "\n",
    "xinjianglist= [i for i in district if \"65\" in i[:2] and \"00\"!=i[4:7]]\n",
    "    \n",
    "wushilist=[i for i in xinjianglist if int(i)<650205]\n",
    "import datetime, random\n",
    "min_date=datetime.date(1970,1,1)\n",
    "max_date=datetime.date(2000,1,1)\n",
    "def next_date(start_date,end_date):\n",
    "    #\n",
    "    for i in range(100000):\n",
    "        t=start_date+datetime.timedelta(i)\n",
    "        if (t).__gt__(end_date) :\n",
    "            break\n",
    "        else:\n",
    "            yield  t.strftime(\"%Y%m%d\")\n",
    "\n",
    "# for i in next_date(min_date,max_date):\n",
    "#     print(i)\n",
    "date_list=[i for i in next_date(min_date,max_date)]\n",
    "def gen_idcard(rand_num=999):\n",
    "    with open(\"X:\\id_wushi.txt\",\"w\") as f:\n",
    "        for i in wushilist:\n",
    "            for j in date_list:\n",
    "                for k in range(rand_num):\n",
    "                    idcard= i+j+str(k).zfill(3)#str(random.randint(0,999)).zfill(3)\n",
    "                    f.writelines(\"\\n\"+mod11(idcard)) \n",
    "            print(i)\n",
    "\n",
    "    \n",
    "gen_idcard()  \n",
    "# yearlist=[ i  for i in range(1970,2010)]\n",
    "# day=[ str(i).zfill(2) for i in range(1,32)]\n",
    "# month_day_list=[i for i in [\"01\",\"03\",\"05\",\"07\",\"08\",\"10\",\"12\"]]+[i for i in [\"4\",\"6\",\"9\",\"11\"]]+[\"02\"]\n",
    "# month_day_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'330102199404102229'"
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def mod11(num):\n",
    "    \"\"\"\n",
    "    >>>mod11(\"33010219940410222\")\n",
    "    \"9\"\n",
    "    \"\"\"\n",
    "    if len(num)>17:\n",
    "        raise UserWarning(\">17\")\n",
    "    quan=[7    , 9     ,10    ,5     ,8    , 4     ,2     ,1     ,6     ,3     ,7     ,9     ,10    ,5     ,8     ,4     ,2 ]\n",
    "    r=['1', '0', 'X' , '9', '8', '7', '6', '5', '4', '3', '2']\n",
    "    sum=0\n",
    "    for i,j in zip(num,quan):\n",
    "        temp=int(i)*j\n",
    "        sum+=temp\n",
    "    mod=sum%11\n",
    "    \n",
    "    return num+r[mod]\n",
    "\n",
    "mod11(\"33010219940410222\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "181205:17:59:33\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<Thread(Thread-7, initial)>"
      ]
     },
     "execution_count": 78,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import sched,time ,threading\n",
    "s = sched.scheduler(time.time,time.sleep) \n",
    "def print_time():\n",
    "    print(time.strftime('%y%m%d:%H:%M:%S')) \n",
    "\n",
    "threading.Thread(target=print_time())\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "111 4 2\n"
     ]
    }
   ],
   "source": [
    "a=3\n",
    "b=1\n",
    "f\"{a,b}\"\n",
    "\n",
    "def aa(b=3,c=4,**k):\n",
    "    print(b,c,k[\"d\"])\n",
    "aa(**{\"d\":2,\"b\":111})"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.6"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
